//
// Page.h
// Usage: Page descriptor
// CreateDate: 2009-03-11
// Author: MaJiuyue
//
#ifndef _PAGE_H_
#define _PAGE_H_

#include "type.h"
#include "list.h"

#define PG_reserved	1	/* Page is reserved or dynamic alloc */
#define PG_private	2

class Page : public list_head<Page>
{
private:
	u32 flags;			// flags, not used
	u32 _count;			// refernce count
	u32 _private;			// private values for special used
	u32 _reserved;

public:
	Page() { flags=0; _count=0; _private=0; }

	/* PG_private bit */
	void SetPagePrivate(u32 __private) { _private = __private; flags |= PG_private; }
	void ClearPagePrivate() { _private = 0; flags &= ~PG_private; }

	bool IsBuddy(int order) { 
		return ( (flags&PG_private) && ((int)_private == order) && !(flags&PG_reserved) && (_count==0) );
	}

	/* PG_reserved bit */
	void SetReserved() { flags |= PG_reserved; }
	void ClearReserved() { flags &= ~PG_reserved; }
	bool IsReserved() { return flags&PG_reserved; }
};

#endif

